package com.jyf.redis.common.model;

/**
 * 服务器端发生错误时的错误对象
 * @author jyf
 * @time 2020/11/9 20:03
 */
public final class ErrorResult {

    /**
     * 状态码，200成功，400失败
     */
    private Integer code = 400;
    /**
     * 错误码，自定义
     */
    private String errorCode;
    /**
     * 错误信息
     */
    private String errorMessage;
    /**
     * 给用户的提示信息
     */
    private String tips;


    /**
     * 构建返回错误对象
     * @param errorCode 错误码
     * @param errorMessage 错误信息
     * @param tips 给用户的提示信息
     * @return
     */
    public static ErrorResult build(String errorCode, String errorMessage, String tips){
        return new ErrorResult(errorCode,errorMessage,tips);
    }



    private ErrorResult(String errorCode, String message, String tips) {
        this.errorCode = errorCode;
        this.errorMessage = message;
        this.tips = tips;
    }


    private ErrorResult() {
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getTips() {
        return tips;
    }

    public void setTips(String tips) {
        this.tips = tips;
    }

    @Override
    public String toString() {
        return "ErrorResult{" +
                "code=" + code +
                ", errorCode='" + errorCode + '\'' +
                ", errorMessage='" + errorMessage + '\'' +
                ", tips='" + tips + '\'' +
                '}';
    }
}
